
<%@page import="com.guias.consultas.ConsultasBasicas"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.guias.data.Ejecutar"%>
<%@page import="java.util.ArrayList"%>
<%

String gs_opcion = (request.getParameter("opcion")!=null)? request.getParameter("opcion") : "";

if (gs_opcion.equals("1")){
    String cantidad = (request.getParameter("cantidad")!= null)? request.getParameter("cantidad") : "1";
    String operador = (request.getParameter("oper")!=null)? request.getParameter("oper") : "0";
    operador = (operador.equals("0")) ? ">" : "=";
    String sql_select = "select * from ( select count(2) cantidad, c.NOMBRE, b.id_cosmos from tb_historial_inscrito b, tb_inscritos c where b.id_cosmos = c.id_cosmos group by b.id_cosmos order by 1 desc ) a where a.cantidad "+operador+" "+cantidad;
    ArrayList ly_datos = new ArrayList();
    ArrayList ly_campos = new ArrayList();
    Ejecutar exec = new Ejecutar();
    ly_datos = exec.ejecutarSQLselect(sql_select, false);
    if (ly_datos!=null){
        %>
            <table id="datos" border="1" >
                <thead> 
                    <tr> 
                        <th>Cantidad</th> 
                        <th>Nombre</th> 
                        <th>Guias</th>
                    </tr> 
                </thead> 
                <tbody>
         <% 
         for (Iterator it = ly_datos.iterator(); it.hasNext();){
             ly_campos = (ArrayList) it.next();
             if (ly_campos != null){
                 String cant = (String) ly_campos.get(0);
                 String nombre = (String) ly_campos.get(1);
                 String id_cosmos = (String) ly_campos.get(2);
                 String div_destino = "divc_"+ id_cosmos.trim();
                 %>                
                 
                    <tr onclick="javascript:detalleGuias('<%=id_cosmos%>')">
                         <td><%=cant%></td>
                         <td><%=nombre%></td>
                         <td><div class="guias" id="<%=div_destino%>"></div></td>
                    </tr>
                 
                 
                 <% 
             }
         }
    }
}

%>